<?php

/**
 * Performs a login, generates and prints the view for the result
 * @param string $name
 * @param string $password
 */
function login($name, $password){
	$sessionID = SessionManager::login($name, $password);
	if(is_null($sessionID)){
		$res = new ResultJSON(true, '', SessionManager::getLastError());
		echo $res->renderView();
	} else {
		$res = new ResultJSON(false, $sessionID);
		$res->addItem('uID', $_SESSION['USER_ID']);
		echo $res->renderView();
	}
}

?>